package com.moxiao.yfjh.module.blind.dal.mysql.distributionsharing;

import com.moxiao.yfjh.framework.common.pojo.PageResult;
import com.moxiao.yfjh.framework.mybatis.core.mapper.BaseMapperX;
import com.moxiao.yfjh.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.moxiao.yfjh.module.blind.controller.admin.distributionsharing.vo.DistributionSharingExportReqVO;
import com.moxiao.yfjh.module.blind.controller.admin.distributionsharing.vo.DistributionSharingPageReqVO;
import com.moxiao.yfjh.module.blind.dal.dataobject.distributionsharing.DistributionSharingDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 相亲分销分享 Mapper
 *
 * @author mx
 */
@Mapper
public interface DistributionSharingMapper extends BaseMapperX<DistributionSharingDO> {

    default PageResult<DistributionSharingDO> selectPage(DistributionSharingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DistributionSharingDO>()
                .eqIfPresent(DistributionSharingDO::getShareUserId, reqVO.getShareUserId())
                .eqIfPresent(DistributionSharingDO::getShareUserIp, reqVO.getShareUserIp())
                .eqIfPresent(DistributionSharingDO::getSystem, reqVO.getSystem())
                .eqIfPresent(DistributionSharingDO::getDeviceType, reqVO.getDeviceType())
                .eqIfPresent(DistributionSharingDO::getDeviceId, reqVO.getDeviceId())
                .eqIfPresent(DistributionSharingDO::getIp, reqVO.getIp())
                .betweenIfPresent(DistributionSharingDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DistributionSharingDO::getId));
    }

    default List<DistributionSharingDO> selectList(DistributionSharingExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DistributionSharingDO>()
                .eqIfPresent(DistributionSharingDO::getShareUserId, reqVO.getShareUserId())
                .eqIfPresent(DistributionSharingDO::getShareUserIp, reqVO.getShareUserIp())
                .eqIfPresent(DistributionSharingDO::getSystem, reqVO.getSystem())
                .eqIfPresent(DistributionSharingDO::getDeviceType, reqVO.getDeviceType())
                .eqIfPresent(DistributionSharingDO::getDeviceId, reqVO.getDeviceId())
                .eqIfPresent(DistributionSharingDO::getIp, reqVO.getIp())
                .betweenIfPresent(DistributionSharingDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DistributionSharingDO::getId));
    }
}
